import BaseModel from "../../../cfw/mvc/BaseModel";
import ModelManager from "../../../cfw/mvc/ModelManager";
import FoodItemModel from "./FoodItemModel";
import ModuleManager from "../../../cfw/module/ModuleManager";
import StateItemModel from "../../player/model/StateItemModel";
import Player from "../../player/Player";
import { PlayerStateID } from "../../../public/Config";


export default class DininghallManager extends BaseModel {

    private static ins: DininghallManager;
    static instance() {
        if (!this.ins) {
            this.ins = new DininghallManager()
        }
        return this.ins;
    }

    private playerState: StateItemModel

    private itemMgr: ModelManager<FoodItemModel> = new ModelManager()


    constructor() {
        super();
        this.playerState = Player.instance().getStateItemModel(PlayerStateID.EATING)
        this.itemMgr.initWithData(ModuleManager.dataManager.get(FoodItemModel.CLASS_NAME), FoodItemModel)
    }

    addNum(food: FoodItemModel) {
        this.playerState.addNum(food.getCleanNum())
    }

    updateExp() {
        Player.instance().updateExp(this.playerState)
    }

    getList() {
        return this.itemMgr.getList()
    }

    getItem(id: number) {
        return this.itemMgr.getByID(id)
    }
}
